package com.javabasic.algorithm.cometoj;

import java.io.PrintWriter;
import java.util.*;

public class 迫真小游戏 {

    private static Scanner cin = new Scanner(System.in);
    private static PrintWriter cout = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = cin.nextInt();
        int[] book = new int[n+1];
        Set<Integer> set = new TreeSet<>();
        Set<Integer> set1 = new TreeSet<>();
        Map<Integer, List<Integer> > map = new HashMap<>();
        for (int i = 1; i <= n; i++) {
            map.put(i,new ArrayList<Integer>());
        }
        int from, to;
        for (int i = 0; i < n; i++) {
            from = cin.nextInt();
            to = cin.nextInt();
            map.get(from).add(to);
            map.get(to).add(from);
        }
        int root = 1, k = 0;
        book[root] = 1;
        System.out.print("1 ");
        while (true) {
            if (k%2 == 0) {
                set.addAll(map.get(root));
                for (Integer x : set) {
                    if (book[x] == 0) {
                        book[x] = 1;
                        System.out.print(x + " ");
                        set1.addAll(map.get(x));
                    }
                }
                set.clear();
            } else {
                set1.addAll(map.get(root));
                for (Integer x : set1) {
                    if (book[x] == 0) {
                        book[x] = 1;
                        System.out.print(x + " ");
                        set.addAll(map.get(x));
                    }
                }
                set1.clear();
            }

            k++;
            if (set.size() == 0 && set1.size() == 0) break;

        }
//        System.out.println("Over");


    }
}
